package top.yaofengqiao.springcloudsimple.demo.biz.trigger.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;
import top.yaofengqiao.springcloudsimple.common.constant.MQConstant;
import top.yaofengqiao.springcloudsimple.demo.biz.domain.order.service.IOrderService;

import javax.annotation.Resource;

/**
 * @author yfq
 * @date 2024/6/22 13:44
 * @description 订单关闭监听
 */
@Slf4j
@Service
@RocketMQMessageListener(topic = MQConstant.ORDER_DELAY_TOPIC,
        consumerGroup = MQConstant.ORDER_GROUP,
        selectorExpression = MQConstant.ORDER_CLOSE_TAG)
public class OrderCloseListener implements RocketMQListener<String> {
    @Resource
    private IOrderService orderService;

    @Override
    public void onMessage(String rechargeOrderNo) {
        log.info("接收到订单关闭消息：{}", rechargeOrderNo);
        orderService.orderClose(rechargeOrderNo);
    }

}
